<!doctype html>
<html lang="zh-CN">
 <head> 
  <meta charset="UTF-8"> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <title>注册</title> 
  <link href="{{url_for('main.static', filename='css/bootstrap.min.css')}}" rel="stylesheet"> 
  <link href="{{url_for('admin.static', filename='css/custom.min.css')}}" rel="stylesheet"> 
  <link href="{{url_for('main.static', filename='css/iconfont.css')}}" rel="stylesheet"> 
  <link href="{{url_for('main.static', filename='css/online.min.css')}}" rel="stylesheet"> 
  <link href="{{url_for('main.static', filename='css/main.css')}}" rel="stylesheet"> 
  <script src="{{url_for('admin.static',filename='js/jquery.min.js')}}"></script>
  <script src="{{url_for('admin.static',filename='ajax/libs/validate/jquery.validate.min.js')}}"></script>
  <script src="{{url_for('admin.static',filename='ajax/libs/validate/messages_zh.min.js')}}"></script>
  <script src="{{url_for('admin.static',filename='ajax/libs/validate/jquery.validate.extend.js')}}"></script>
 </head> 
 <body style="background:#F8F9FA;"> 
  <div class="sign-wrapper"> 
   <div class="header"> 
    <div class="inner container"> 
     <h1 class="title"> <img src="{{url_for('main.static', filename='images/5f0741a03e9de.png')}}" alt="logo" style="display: none;"> 公共平台 </h1> 
     <span class="handle"> <a href="{{url_for('admin.login')}}"> <i class="iconfont icon-entrence"></i> 机构登录 </a> </span> 
    </div> 
   </div> 
   <form id="w0" method="post">
    <input id="csrf_token" name="csrf_token" type="hidden" value="{{ csrf_token() }}">
    <div class="sign-up-form"> 
     <div class="inner container"> 
      <h2 class="title"> 机构注册 </h2> 
      <h3 class="subtitle"> <span class="icon"> <i class="iconfont icon-student"></i> </span> 用户信息 </h3> 
      <div class="container-fluid"> 
       <div class="col-10"> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">姓名</label> 
         <div class="col-7"> 
          <input type="text" maxlength="50" class="form-control" name="user_name" value="" required> 
         </div> 
        </div> 
        <div id="username-row" class="form-group  row has-required  "> 
         <label class="col-4 col-form-label">手机号码</label> 
         <div class="col-7"> 
          <input type="text" id="username" class="form-control" name="user_mobile" value="" required> 
          <div class="help-block" id="tip"> 
          </div> 
         </div> 
        </div> 
        <!-- 图形验证码开始 --> 
        <div id="img-row" class="form-group has-required row "> 
         <label class="col-4 col-form-label">验证码</label> 
         <div class="col-7"> 
          <div class="flex-inline"> 
           <input type="text" id="code" class="form-control" name="captcha" required>
           <img id="code-image" class="img-code" src="{{url_for('admin.captcha')}}" alt="点击刷新验证码" style="cursor:pointer;"> 
          </div> 
          <div class="help-block" id="imgcode"> 
          </div> 
         </div> 
        </div> 
        <!-- 图形验证码结束--> 
        <div class="form-group has-required row "> 
         <label class="col-4 col-form-label">短信验证码</label> 
         <div class="col-7 "> 
          <div class="flex-inline"> 
           <input type="text" class="form-control" name="mcode" value="" required> 
           <button id="getcode" class="btn btn-outline-primary" style="margin-left:10px;"> 发送验证码 </button> 
          </div> 
          <div class="tips">
            手机号码作为网站登录帐号使用 
          </div> 
          <div class="help-block"> 
          </div> 
         </div> 
        </div> 
        <div class="form-group row has-required  "> 
         <label class="col-4 col-form-label">登录密码</label> 
         <div class="col-7"> 
          <input class="form-control" maxlength="20" type="password" name="password" value="" required> 
         </div> 
        </div> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">确认密码</label> 
         <div class="col-7"> 
          <input class="form-control" type="password" maxlength="20" name="repassword" value="" required> 
         </div> 
        </div> 
       </div> 
      </div> 
      <h3 class="subtitle"> <span class="icon"> <i class="iconfont icon-entrence"></i> </span> 机构信息 </h3> 
      <div class="container-fluid"> 
       <div class="col-10"> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">机构名称</label> 
         <div class="col-7"> 
          <input class="form-control" maxlength="50" type="text" name="name" value="" required> 
         </div> 
        </div> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">所属地区</label> 
         <div class="col-7">  
          <input type="hidden"> 
          <div class="city flex-inline" style="position: relative;">
           <select id="tenantmodel-city" class="prov form-control" name="province" style="" required> </select>
           <select id="tenantmodel-city" class="city form-control" name="city" disabled style="" required> </select>
           <select id="tenantmodel-city" class="dist form-control" name="dist" disabled style="" required> </select>
          </div>  
         </div> 
        </div> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">机构地址</label> 
         <div class="col-7"> 
          <input class="form-control" maxlength="100" type="text" name="addr" value="" required> 
         </div> 
        </div> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">机构性质</label> 
         <div class="col-7"> 
          <select class="form-control custom-select" name="nature" required> 
              <option value=""></option> 
              <option value="政府机关">政府机关</option> 
              <option value="事业单位">事业单位</option> 
              <option value="企业">企业</option> 
              <option value="社会培训机构">社会培训机构</option> 
              <option value="技工院校">技工院校</option> 
              <option value="职业院校">职业院校</option> 
              <option value="高等学校">高等学校</option> 
              <option value="其他">其他</option> 
            </select> 
         </div> 
        </div> 
        <div class="form-group row has-required "> 
         <label class="col-4 col-form-label">机构规模</label> 
         <div class="col-7"> 
          <select class="form-control custom-select" name="scale" required> 
              <option value=""></option> 
              <option value="0-100人">0-100人</option> 
              <option value="100-500人">100-500人</option> 
              <option value="500-2000人">500-2000人</option> 
              <option value="2000-5000人">2000-5000人</option> 
              <option value="5000人以上">5000人以上</option> 
            </select> 
         </div> 
        </div> 
        <div class="form-group row"> 
         <label class="col-4 col-form-label">年开班量</label> 
         <div class="col-7"> 
          <select class="form-control custom-select" name="class_num_year"> 
              <option value="0"></option> 
              <option value="0-20">0-20</option> 
              <option value="21-50">21-50</option> 
              <option value="51-100">51-100</option> 
              <option value="101-200">101-200</option> 
              <option value="200以上">200以上</option> 
            </select> 
         </div> 
        </div> 
        <div class="form-group row"> 
         <label class="col-4 col-form-label">年学员量</label> 
         <div class="col-7"> 
          <select class="form-control custom-select" name="student_num_year"> 
              <option value="0"></option> 
              <option value="0-1000">0-1000</option> 
              <option value="1001-3000">1001-3000</option> 
              <option value="3001-5000人">3001-5000人</option> 
              <option value="5001-1万">5001-1万</option> 
              <option value="1万以上">1万以上</option> 
            </select> 
         </div> 
        </div> 
        <div class="form-group row"> 
         <div class="col-7 offset-4"> 
          <div style="text-align:center;margin-bottom:20px"> 
           <label class="custom-control custom-checkbox"> 
               <input type="checkbox" class="" id="read" name="is_read"> 
               
               <span class="custom-control-description"> 阅读并同意<a href="{{url_for('admin.regist_agreement')}}" target="_blank">服务协议</a> </span> </label>
          </div>  
          <button class="btn btn-primary btn-block" type="button" id="sumBtn" disabled> 提交 </button> 
         </div> 
        </div> 
       </div> 
      </div> 
     </div>  
     <script type="text/javascript">
        var flag = true;
        
        $(function(){
            if ( $('#read').is(":checked") ){
                $("#sumBtn").removeAttr('disabled');
            }

            $("#read").click(function(){
                $("#sumBtn").attr('disabled','disabled');
                if ( $(this).is(":checked")  ){
                    $("#sumBtn").removeAttr('disabled');
                }
            });

            $("#w0").validate();

            $("#sumBtn").click(function(event) {
                if( !$("#w0").validate().form()) {
                    return false;
                }
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "{{url_for('admin.regist')}}",
                    data: $("#w0").serialize(),
                    beforeSend: function(xhr, settings) {
                        var csrftoken = $('meta[name=csrf-token]').attr('content')
                        if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
                            xhr.setRequestHeader("X-CSRFToken", csrftoken)
                        }
                    },
                    success: function(data) {
                        console.log(data)
                        alert(data.msg)
                        if( data.code == 0 ){
                            $("#sumBtn").attr('disabled','disabled');
                            window.location.href = "{{url_for('admin.login')}}";
                            return false;
                        }

                    }
                });
                // event.preventDefault();
                return false;
            });

            $("#getcode").click(function() {
                if ( flag == false ){
                    return false;
                }
                flag = false;
                reset();
                var mobile = $('#username').val();
                if (!mobile) {
                    $('#username-row').addClass('has-danger');
                    $('#tip').html("请输入手机号码");
                    flag = true;
                    return false;
                }

                if ( !/^1\d{10}$/.test(mobile) ){
                    $('#username-row').addClass('has-danger');
                    $('#tip').html("手机号码不正确");
                    flag = true;
                    return false;
                }


                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "{{url_for('admin.reg_mcode')}}",
                    data: {
                        "mobile": mobile,
                        "captcha"  : $('#code').val(),
                    },
                    beforeSend: function(xhr, settings) {
                        var csrftoken = $('meta[name=csrf-token]').attr('content')
                        if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
                            xhr.setRequestHeader("X-CSRFToken", csrftoken)
                        }
                    },
                    success: function(data) {
                        console.log(data)
                        flag = true;
                        if( data.code == 501 ){
                            $('#img-row').addClass('has-danger');
                            $('#imgcode').html(data.msg);
                            return false;
                        }

                        if (data.code == 502) {
                            $('#username-row').addClass('has-danger');
                            $('#tip').html(data.msg);
                            return false;
                        }

                        if (flag){
                            coldDown($("#getcode"));
                        }

                    }
                });
                return false;
            });


            function reset(){
                $('#username-row').removeClass('has-danger');
                $('#img-row').removeClass('has-danger');
                $('#tip').html('');
                $('#imgcode').html('');
            }


            var limit = 90;

            function coldDown(ob) {
                if (limit == 0) {
                    flag = true;
                    ob.removeAttr('disabled');
                    ob.removeAttr('style');
                    ob.text("获取验证码");
                    ob.css('margin-left', '10px');
                    limit = 90;
                    return;
                } else {
                    ob.prop('disabled', true);
                    ob.css('color', 'rgba(0,0,0,.3)');
                    ob.css('border', '1px solid rgba(0,0,0,.3)');
                    ob.text("重发(" + limit + ")");
                    limit--;
                }
                setTimeout(function() {
                    coldDown(ob)
                }, 1000) //每1000毫秒执行一次
            }

        });
    </script> 
     <div class="modal fade" id="idm-tenant-alert" role="dialog" aria-hidden="true"> 
      <div class="modal-dialog" role="document"> 
       <div class="modal-content" style="width:500px"> 
        <div class="modal-header"> 
         <h5 class="modal-title" id="idm-tenant-alert-title">系统提示</h5> 
         <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> 
        </div> 
        <div class="modal-body" id="idm-tenant-alert-body"> 
         <h4 class="layer-single-line text-center padding-v"> <i id="idm-tenant-alert-icon" class="iconfont icon-i-alert"></i> <span id="idm-tenant-alert-msg"></span> </h4> 
        </div> 
        <div class="modal-footer"> 
         <div class="buttons-wrapper"> 
          <button id="idm-tenant-alert-ok" type="button" class="btn btn-secondary">确认</button> 
         </div> 
        </div> 
       </div> 
      </div> 
     </div> 
     <script src="{{url_for('main.static', filename='js/yii.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/yii.captcha.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/tether.min.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/bootstrap.min.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/clipboard.min.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/webSite.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/city.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/jquery.cityselect.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/yii.activeForm.js')}}"></script> 
     <script src="{{url_for('main.static', filename='js/global.js')}}"></script> 
     <script type="text/javascript">jQuery(function ($) {
         $("#code-image").click(function () {
            $(this)[0].src ="{{url_for('admin.captcha')}}?"+Math.random()
        })
                $(".city").citySelect({
                    nodata:"block",
                    prov:"",
                    city:"",
                    dist:"",
                    required:false,disabled:0
                });
        
        jQuery('#w0').yiiActiveForm([], []);

        $(document).keydown(function(event){
            if (event.keyCode == 13 && $("#idm-tenant-alert").css("display") == "block") {
                return false;
            }
        });
    

    $("#addmodel-parentid ").on("click",".dropdown-clear-all",function(){
        $('.city .prov').removeAttr("disabled");
        $('.city .prov').val("");
        $('.city .prov').change();
    });

    
    $("#addmodel-parentid").on("click","ul li",function(){
        var parentId = $(this).attr("data-value");
        $.ajax({
            type:"POST",
            dataType:"json",
            url: "/tenant/common/ajax-city?guid=E41D4312-AB9E-2DC5-3BFD-63BAD089EF31",
            data:"parentId="+parentId,
            success:function(data){
                if(data.success){
                    $('.city .prov').val(data.message);
                }else{
                    $('.city .prov').val("");
                    $("#idm-tenant-alert-icon").attr("class", "iconfont icon-error");
                    $("#idm-tenant-alert-msg").html(data.message);
                    $("#idm-tenant-alert").modal({ show:true, backdrop:"static"});
                }
                $('.city .prov').change();
                $('.city .prov').prop("disabled",true);
            }
        });
    });
    
    $("#addmodel-packageid").change(function() {
        var val= $(this).val();
        if (val !='' || val != 'undefined') {
            $.ajax({
                type:"POST",
                dataType:"json",
                url: "/tenant/common/ajax-package?guid=E41D4312-AB9E-2DC5-3BFD-63BAD089EF31",
                data:"packageId="+val,
                success:function(data){
                    if(data.success){
                        if(data.message == 0){
                            $("#addmodel-validtime").val(0).prop('disabled',true);
                        }else {
                            $("#addmodel-validtime").val('').prop('disabled',false);
                        }
                        
                    }else{
                        $("#idm-tenant-alert-icon").attr("class", "iconfont icon-error");
                        $("#idm-tenant-alert-msg").html(data.message);
                        $("#idm-tenant-alert").modal({ show:true, backdrop:"static"});
                    }
                }
            });
        }
    });
    

    $("#idm-tenant-alert-ok").click(function() {
        $("#idm-tenant-alert").modal('hide');
        if (window.reload){
            location.reload();
        } 
    });
    $(function(){
        
        // 如果选择了上级租户，租户区域的省份不可更改
        var parentId = $("select[name='AddModel[parentId]']").val();
        if(parentId>0){
             $('.city .prov').change();
             $('.city .prov').prop("disabled",true);
        }
    });
    
    $("#saveBtn").click(function(){
        $(this).prop("disabled",true);
        $('.city .prov').removeAttr("disabled");
        $("#addmodel-validtime").removeAttr("disabled");
        $("#saveForm").submit();
    });
});</script> 
     <div class="footer">
        职业技能公共服务学习平台
      <br> 
      <a href="https://beian.miit.gov.cn" target="_black" style="color: inherit;">京ICP备20032147号-2</a> 
     </div> 
    </div>
   </form>   
   <script type="text/javascript">
    function createTag(text, $color) {
        const tag = document.createElement('div');

        tag.style.cssText = 'position:fixed;left:50%;top:0px;color:#fff;transform:translateX(-50%);font-size:16px;z-index:9999; background-image:url(' + $color + ');background-size:100% 100%;background-repeat:no-repeat; padding:5px 0px 10px;text-align:center;min-width:200px;';
        tag.innerText = text;
        tag.className = "env_flag";
        document.body.appendChild(tag);
    }

    //只有非生产环境才显示该标识
    if ("production" != 'production') {
        var blue   = "https://s.ataclass.cn/s-ataclass-cn/images/blue.png";
        var green  = "https://s.ataclass.cn/s-ataclass-cn/images/green.png";
        var orange = "https://s.ataclass.cn/s-ataclass-cn/images/orange.png";
        var color = "";
        var env = "";
        if ("production" == "demo") {
            color = green;
            env = "演示环境";
        } else if ("production" == "uat") {
            color = blue;
            env = "开发环境";
        } else {
            color = orange;
            env = "测试环境";
        }
        createTag(env, color);
    }
</script> 
  </div>
 </body>
</html>